import os

import dotenv
from pydantic.v1 import BaseSettings

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

# 文件存储
DOWNLOADS_DIR = os.path.join(BASE_DIR, "downloads")
os.makedirs(DOWNLOADS_DIR, exist_ok=True)


class Settings(BaseSettings):
    """配置类"""
    dotenv.load_dotenv(dotenv.find_dotenv(), override=True)
    # 调试模式
    APP_DEBUG: bool = True
    # 项目信息
    VERSION: str = "0.0.1"
    PROJECT_NAME: str = "weekly-report"
    DESCRIPTION: str = '<a href="/redoc" target="_blank">redoc</a>'

    # 静态资源目录
    STATIC_DIR: str = os.path.join(os.getcwd(), "static")

    # 跨域请求
    CORS_ORIGINS: list = ["*"]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: list = ["*"]
    CORS_ALLOW_HEADERS: list = ["*"]

    # Session
    SECRET_KEY = "session"
    SESSION_COOKIE = "session_id"
    SESSION_MAX_AGE = 14 * 24 * 60 * 60


settings = Settings()
